package com.gxa.www.cl.service.impl;

import com.gxa.www.cl.domain.vo.PurchaseOrders;
import com.gxa.www.cl.mapper.PurchaseDetailMapper;
import com.gxa.www.cl.common.util.PurchaseDetail;
import com.gxa.www.cl.mapper.PurchaseDetailMapper;
import com.gxa.www.cl.service.PurchaseDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PurchaseDetailServiceImpl implements PurchaseDetailService {

    @Autowired
    private PurchaseDetailMapper purchaseDetailMapper;

    // 获取采购单信息
    public List<PurchaseDetail> getPurchaseDetails() {
        return purchaseDetailMapper.getPurchaseDetails();
    }

    // 添加采购明细
    public String addPurchaseDetail(PurchaseDetail purchaseDetail) {
        int result = purchaseDetailMapper.insertPurchaseDetail(purchaseDetail);
        if (result > 0) {
            return "添加成功";
        } else {
            return "添加失败";
        }
    }

    // 获取药品类别
    public List<String> getMedicineCategories() {
        return purchaseDetailMapper.getMedicineCategories();
    }

    // 根据类别获取药品
    public List<String> getMedicinesByCategory(String category) {
        return purchaseDetailMapper.getMedicinesByCategory(category);
    }

    @Override
    public List<PurchaseOrders> getPurchaseOrders() {
        return purchaseDetailMapper.getPurchaseOrders();
    }

    @Override
    public void DeletePurchaseOrders(Integer id) {
        purchaseDetailMapper.DeletePurchaseOrders(id);
    }

    @Override
    public void UpdatePurchaseOrders(PurchaseOrders purchaseOrders) {
        purchaseDetailMapper.UpdatePurchaseOrders(purchaseOrders);
    }
}
